package co.yixiang.modules.shop.rest;

import co.yixiang.aop.log.Log;
import co.yixiang.modules.shop.domain.YxUserFeedbackInfo;
import co.yixiang.modules.shop.service.YxUserFeedbackService;
import co.yixiang.modules.shop.service.dto.YxUserFeedbackDto;
import co.yixiang.modules.shop.service.dto.YxUserFeedbackQueryCriteria;
import co.yixiang.modules.shop.service.dto.YxUserQueryCriteria;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.data.domain.Pageable;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName : YxUserFeedbackController
 * @Description :
 * @Author : DragonUncle
 * @Date :  17:08 2020/5/27
 */
@Api(tags = "反馈管理")
@RestController
@RequestMapping("/api/userFeedback")
public class YxUserFeedbackController {

    private final YxUserFeedbackService yxUserFeedbackService;

    public YxUserFeedbackController(YxUserFeedbackService yxUserFeedbackService) {
        this.yxUserFeedbackService = yxUserFeedbackService;
    }


    @GetMapping
    @Log("查询反馈")
    @ApiOperation("查询反馈")
    @PreAuthorize("@el.check('userFeedback:list')")
    public ResponseEntity<Map> getUserFeedback(YxUserFeedbackQueryCriteria feedbackQueryCriteria, Pageable pageable){

        HashMap<String, Object> stringObjectHashMap = new HashMap<>();

        stringObjectHashMap.put("code",200);
        stringObjectHashMap.put("message",yxUserFeedbackService.queryAll(feedbackQueryCriteria,pageable));

        return ResponseEntity.ok( stringObjectHashMap);
    }
    @PutMapping
    @Log("修改反馈")
    @ApiOperation("修改反馈")
    @PreAuthorize("@el.check('userFeedback:edit')")
    public ResponseEntity<Map<String,Object>> modificationUserFeedback(@Validated @RequestBody YxUserFeedbackInfo resources){
        yxUserFeedbackService.delete(resources);
        HashMap<String, Object> stringObjectHashMap = new HashMap<>();
        stringObjectHashMap.put("code",200);
        return ResponseEntity.ok( stringObjectHashMap);
    }


}
